home *** CD-ROM | disk | FTP | other *** search
- Path: grimsel.zurich.ibm.com!usenet
- From: wgk@zurich.ibm.com (Keith Whittingham)
- Newsgroups: comp.lang.c++
- Subject: Re: another overloading question
- Date: 4 Apr 1996 07:14:45 GMT
- Organization: IBM Research, ZRH
- Distribution: world
- Message-ID: <4jvst5$snq@grimsel.zurich.ibm.com>
- References: <4ju98d$3al@panoramix.fi.upm.es>
- Reply-To: wgk@zurich.ibm.com
- NNTP-Posting-Host: pine.zurich.ibm.com
- X-Newsreader: IBM NewsReader/2 v1.00
-
- In <4ju98d$3al@panoramix.fi.upm.es>, sacha@diafi.upm.es (Sacha) writes:
- >
- >Hi,
- >
- >Can I overload = for simple types?
- >
- > Colour colour(0.99238, 0.172364, 0.273);
- >
- > int intensity = colour;
- >
- > class Colour
- > {
- > private:
- > float r_, g_, b_;
- >
- > public:
- > Colour(float r, float g, float b)
- > {r_=r; g_=g; b_=b;}
- ++++ int operator=(void)
- ++++ { return (r_ + g_ + b_) / 3; }
- > };
- >
- >is there some way I can overload = so that I can do things like:
- >
- > Colour colour(0.99238, 0.172364, 0.273);
- >
- > int intensity = colour;
- >
-
- That should do the trick
-
- Keith
-
-
-